<?php namespace app\admin\controller;

use houdunwang\request\Request;
use system\model\Config;
use houdunwang\config\Config as Configs;
/**
 *  微信配置秘钥控制器
 * Class Weixin
 * @package app\admin\controller
 */
class Weixin extends Common
{
	public function __construct()
	{
		//触发控制器中间件运行登录判断
		$this->auth();
	}
	//动作
	public function setting ( Config $config )
	{
//		p(Configs::get('wechat.appid'));
//		p(Configs::get('wechat.appsecret'));
//		p(Configs::get('wechat.cache_path'));
		if ( IS_POST ) {
			$config->setWexinConfig(Request::post());

			return $this->setRedirect( 'refresh' )->success( '操作成功' );
		}
		$model = Config::find(1);
		$field = $model ? json_decode($model['weixin'],true) : [];

		return view( '' ,compact('field'));
	}
}
